package d5_jdk8_time;

import java.lang.reflect.GenericDeclaration;
import java.time.Duration;
import java.time.LocalDateTime;

public class Test8_Duration {
    public static void main(String[] args) {
        //获取时间点,创建LocalDateTime对象的of方法进行指定时间点,封装时间
        LocalDateTime start = LocalDateTime.of(2025, 11, 11, 11, 11, 11, 11);
        LocalDateTime end = LocalDateTime.of(2025, 11, 11, 12, 12, 12, 12);
        //1、调用静态方法得到Duration对象
        Duration duration = Duration.between(start, end);

        //2、获取两个时间对象间隔的信息
        System.out.println(duration.toDays());//间隔多少天
        System.out.println(duration.toHours());//间隔多少个小时
        System.out.println(duration.toMinutes());//间隔多少分
        System.out.println(duration.toSeconds());//间隔多少秒
        System.out.println(duration.toMillis());//间隔多少毫秒
        System.out.println(duration.toNanos());//间隔多少纳秒
        //注意都是相独立的。

    }
}
